What are correct parameters to fetch historical data for provided fields?
Hi,
I want to fetch the historical data for below fields. What is the correct way to fetch the historical data for a specified Date from history? Please find below the fields and code to replicate the results-
fields = ['SetLabel(TR.InstrStatLocationId(StatType=3),location),SetLabel(TR.InstrStatLocation(StatType=3),locationName)',
'SetLabel(TR.CategoryInvestorCount(StatType=3),investorCount),SetLabel(TR.CategoryOwnershipPct(StatType=3),os)',
'SetLabel(TR.InstrStatCatSharesHeld(StatType=3),position)','SetLabel(TR.InstrStatCatShrsHldVal(StatType=3),heldValue)','Curn=USD']
ric = ['GE', 'TT']
def fetch_refinitv_data(universe, field_input):
rd.open_session()
df = rd.get_data(universe=universe, fields=field_input)
rd.close_session()
return df
df = fetch_refinitv_data('GE',fields)
df
Would appreciate any help on the necessary changes to the above code required to fetch the historical data.
Thanks in advance
Best Answer
-
Hi @atul.arya
I would suggest to reach out to the Workspace Helpdesk - F1 (Get Help & Support) to get the exact request to retrieve the data. What they will do is provide the formula to get the specific data you are after. The formula they provide will work within Excel but you can easily convert it to use the Data Library.
For example, this the formula I'm using to get some of the data you are after:
rd.get_data(
universe=["GE"],
fields=['TR.InstrStatLocationId.date', 'TR.InstrStatLocationId', 'TR.InstrStatLocation',
'TR.CategoryInvestorCount', 'TR.CategoryOwnershipPct', 'TR.InstrStatCatSharesHeld',
'TR.InstrStatCatShrsHldVal'],
parameters={'StatType': 3, 'SDate': "2024-01-01", 'EDate': "2024-07-01"}
)Now, looking at your function 'fetch_refinitv_data()', you are opening a session every time you call this function. You should not do this but instead do it once at the start of your application. Also, I would suggest you use CodeBook to play with the formulas before you attempt to write a complete application. Within CodeBook, you should see a number of examples as a guide to help you play and experiment with basic data requests. From there, you can begin to code out your complete application.
Within CodeBook, on the top left, choose __Examples__/ and navigate to the Refinitiv Data Library section. See below.
0
Answers
-
Thank you @nick.zincone for the solution and suggestions.
It worked on Style, Location, and Rotation as they are associated with a StatType. We used
'TR.InstrStatTypeValueId.date' for style, 'TR.InstrStatLocationId.date' for location, 'TR.InstrStatTypeValueId.date' for rotation to get the date columns
How to do the same for Turnover? Here is the code for
'OS', 'POSITION', 'HELDVALUE'
are also different
TR.PctOfSharesOutHeld, TR.SharesHeld, TR.SharesHeldValue
and not ('TR.CategoryOwnershipPct', 'TR.InstrStatCatSharesHeld', 'TR.InstrStatCatShrsHldVal')
I was using it in this way and had to create a pivot then.
fields = ['SetLabel(TR.OwnTrnverRating,turnoverRating)','SetLabel(TR.PctOfSharesOutHeld,os)','SetLabel(TR.SharesHeld,position)',
'SetLabel(TR.SharesHeldValue,heldValue)', 'Curn=USD']
turnover = fetch_refinitv_data(ric,fields)
turnover_pivot = pd.pivot_table(turnover, values= ['OS', 'POSITION', 'HELDVALUE'], index = ['Instrument', 'TURNOVERRATING'], aggfunc = 'sum')
turnover_pivotSo please help me to fetch the last 3 months of Turnover data.
Thank you,
0 -
Thank you @nick.zincone for the solution and suggestions.
It worked on Style, Location, and Rotation as they are associated with a StatType. We used
'TR.InstrStatTypeValueId.date' for style, 'TR.InstrStatLocationId.date' for location, 'TR.InstrStatTypeValueId.date' for rotation to get the date columns
How to do the same for Turnover? Here is the code for
'OS', 'POSITION', 'HELDVALUE'are also different
TR.PctOfSharesOutHeld, TR.SharesHeld, TR.SharesHeldValueand not ('TR.CategoryOwnershipPct', 'TR.InstrStatCatSharesHeld', 'TR.InstrStatCatShrsHldVal')
I was using it in this way and had to create a pivot then.
fields = ['SetLabel(TR.OwnTrnverRating,turnoverRating)','SetLabel(TR.PctOfSharesOutHeld,os)','SetLabel(TR.SharesHeld,position)','SetLabel(TR.SharesHeldValue,heldValue)', 'Curn=USD']turnover = fetch_refinitv_data(ric,fields) turnover_pivot = pd.pivot_table(turnover, values= ['OS', 'POSITION', 'HELDVALUE'], index = ['Instrument', 'TURNOVERRATING'], aggfunc = 'sum')turnover_pivotSo please help me to fetch the last 3 months of Turnover data.
Thank you,
0 -
Hi @atul.arya
Have you had a chance to reach out to the helpdesk as I suggested? This is there area of expertise - specifically around the suggestions of the data and fields to use.
0
Categories
- All Categories
- 6 AHS
- 37 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 367 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 59 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛